

using UnityEngine;

public class PlayerClimbEndState : PlayerState
{
    Vector3 targetPosition;
    float speed = 8f;
    public PlayerClimbEndState(PlayerFSM manager, string animationName) : base(manager, animationName) { }

    public override void OnEnter()
    {
        base.OnEnter();
        parameter.rb.gravityScale = 0;
        SetVelocity(0, 0);
        targetPosition = manager.transform.position + new Vector3(parameter.climbOffsetPosition.x * parameter.facingDirection, parameter.climbOffsetPosition.y, parameter.climbOffsetPosition.z);
    }

    public override void OnUpdate()
    {
        base.OnUpdate();
        if (PlayComplete())
        {
            manager.TransitionState(StateType.Idle);
        }
    }

    public override void OnFixedUpdate()
    {
        base.OnFixedUpdate();
        manager.transform.position = Vector3.MoveTowards(manager.transform.position, targetPosition, speed * Time.deltaTime);
    }

    public override void OnExit() {
        base.OnExit();
        parameter.rb.gravityScale = parameter.Gravity;
     }
}
